// pages/address/address.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag: true,
    idname: [
      { name: '李四', telephone: '15078928146', address: "广州市天河区" }
    ],
    name: null,
    telephone: null,
    address: null
  },
  flags() {
    this.setData({
      flag: false
    })
  },
  flagfalse() {
    this.setData({
      flag: true
    })
  },
  del(options) {
    let index = options.currentTarget.dataset.index
    this.data.idname.splice(index, 1)
    wx.setStorageSync("addresList", this.data.idname);
    let idname = wx.getStorageSync("addresList");
    this.setData({
      idname: idname
    })
  },
  add() {
    let addressList = {
      name: this.data.name,
      telephone: this.data.telephone,
      address: this.data.address
    }
    this.data.idname.push(addressList)
    console.log(this.data.idname);
    wx.setStorageSync("addresList", this.data.idname);
    let idname = wx.getStorageSync("addresList");
    this.setData({
      idname: idname
    })
  },
  replace(options) {
    let index = options.currentTarget.dataset.index
    let idname = this.data.idname
    console.log(idname[index]);
    wx.setStorageSync("idnameIndex", idname[index]);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let idname = wx.getStorageSync("addresList");
    this.setData({
      idname: idname
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})